import Taro, {Component} from '@tarojs/taro'
import { View, Icon, Input, Image, Text, Textarea, Picker, Button, Label, Checkbox} from '@tarojs/components'
import { connect } from '@tarojs/redux'
import styles from './index.module.scss'
import { getResumeList } from '@/api'
import { dialog} from '@/util';
import NoData from "@/components/NoData"

@connect(({user}) => ({
  info: user.info,
}), dispatch => ({
}))
export default class taskList extends Component {

  config = {
    navigationBarTitleText: '个人履历'
  }

  state = {
    list: [],
  }

  componentWillMount = () => {
    this.getList();
  }

  getList = async () => {
    const { info } = this.props;
    try {
      Taro.showLoading({mask: true, title: '数据加载中...'})
      const { data } = await getResumeList({ mobile: info.mobile })
      Taro.hideLoading()
      this.setState({list: data})
    } catch(e) {
      dialog.toast({title: e.message});
    }
  }

  render () {
    let { list } = this.state;
    return (
      <View className={styles.wrapper}>
        <View className={styles.headWrap}>
          <View className={styles.hint}>提示：该页面展示您在众包平台服务过的所有商户</View>
        </View>
        <View className={styles.waitWrap}>
          {
            (list && list.length>0) ? list.map((item, index)=>{
            return(
              <View className={styles.order} key={index + ''}>
                <View className={styles.item}>
                  <Text className={styles.label}>商户名称：</Text>
                  <Text className={styles.value}>{item.merchantName}</Text>
                </View>
                <View className={styles.item}>
                  <Text className={styles.label}>任务名称：</Text>
                  <Text className={styles.value}>{item.taskName}</Text>
                </View>
                <View className={styles.item}>
                  <Text className={styles.label}>起止时间：</Text>
                  <Text className={styles.value}>{item.taskBeginTime}至{item.taskEndTime}</Text>
                </View>
                <View className={styles.item}>
                  <Text className={styles.label}>任务时长：</Text>
                  <Text className={styles.value}>{item.missionDuration}</Text>
                </View>
              </View>
            )
          }) : <NoData></NoData>
        }
        </View>
      </View>
    )
  }
}
